package com.example.contestsystem.Dao;

import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import com.example.contestsystem.Entity.Teacher;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface TeacherRepository extends JpaRepository<Teacher, Integer> {
    Teacher findByTeacherAccount(int teacherId);

    @Modifying
    @Transactional
    @Query("UPDATE Teacher t SET t.teacherPassword = :teacherPassword WHERE t.teacherAccount = :teacherAccount")
    void modifyPassword(@Param("teacherPassword") String teacherPassword, @Param("teacherAccount") int teacherAccount);

    @Modifying
    @Transactional
    @Query("UPDATE Teacher t SET t.teacherName = :teacherName WHERE t.teacherAccount = :teacherAccount")
    void modifyName(@Param("teacherName") String teacherName, @Param("teacherAccount") int teacherAccount);

}
